<template>
  <div class="container">
    <div>
      <el-row :gutter="20">
        <el-col :span="5">
          <el-form ref="form" :model="form">
            <el-form-item label="车辆号牌：">
              <el-input v-model="form.name" placeholder="请输入车牌" style="width:150px;"></el-input>
            </el-form-item>
          </el-form>
        </el-col>
        <el-col :span="9">
          <el-form ref="form" :model="form">
            <el-form-item label="日期：" :label-width="labelwidth">
              <el-date-picker
                v-model="value2"
                type="daterange"
                align="right"
                unlink-panels
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                size="mini"
                :picker-options="pickerOptions">
              </el-date-picker>
            </el-form-item>
          </el-form>
        </el-col>
        <!-- <el-col :span="6">
          <el-form ref="form" :model="form">
            <el-form-item label="车况：">
              <el-select v-model="form.statusValue" placeholder="请选择车辆情况">
                <el-option
                  v-for="(item,index) in form.statusList"
                  :value="item.label"
                  :label="item.value"
                  :key="index"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-form>
        </el-col> -->
        <!-- <el-col :span="6" v-if="form.timeTypeValue === '0'">
          <el-form ref="form" :model="form">
            <el-form-item label="结束日期：" :label-width="labelwidth">
              <el-date-picker
                v-model="form.endDate"
                type="date"
                placeholder="选择日期"
                value-format="yyyy-MM-dd"
              ></el-date-picker>
            </el-form-item>
          </el-form>
        </el-col>-->
        <el-col :span="6">
          <el-form ref="form" :model="form" style="float:left">
            <el-form-item>
              <el-button size="mini" type="primary" @click="getlistdata">查 询</el-button>
              <el-button size="mini" type="success" @click="exportExcel">新增</el-button>
              <el-button size="mini" type="success" @click="exportExcel">删 除</el-button>
            </el-form-item>
            <!-- <el-form-item>
              <el-form ref="form" :model="form" style="float:left">
              <el-button size="mini" type="success" @click="exportExcel">导 入</el-button>
              <el-button size="mini" type="success" @click="exportExcel">导 出</el-button>
            </el-form-item> -->
          </el-form>
        </el-col>
      </el-row>
    </div>
    <el-table :data="tableData.slice((currentPage-1)*pageSize,currentPage*pageSize)">
      <el-table-column  prop="ID" label="序号" align="center" width="120"></el-table-column>
      <el-table-column  prop="Dw" label="车辆ID" align="center" width="150"></el-table-column>
      <el-table-column  prop="Cph" label="车牌号码" align="center" width="120"></el-table-column>
      <el-table-column  prop="Model" label="违章类型" align="center" width="120"></el-table-column>
      <el-table-column  prop="Person" label="违章时间" align="center" width="120"></el-table-column>
      <el-table-column  prop="Buytime" label="违章扣分" align="center" width="120"></el-table-column>
      <el-table-column  prop="Explain" label="违章罚款" align="center" width="150"></el-table-column>
      <el-table-column  prop="Explain" label="违章地点" align="center" width="120"></el-table-column>
      <el-table-column  prop="Explain" label="司机ID" align="center" width="120"></el-table-column>
      <el-table-column  prop="Explain" label="司机姓名" align="center" width="120"></el-table-column>
      <el-table-column  prop="Explain" label="违章路像地址" align="center" width="130"></el-table-column>

    </el-table>
    <div class="pagination">
      <el-pagination
        background
        layout="total, sizes, prev, pager, next, jumper"
        :current-page="currentPage"
        :page-size="pageSize"
        :total="tableData.length"
        @size-change="handleSizeChange"
        @current-change="handlePageChange"
      ></el-pagination>
    </div>
  </div>
</template>
<script>
import '@/assets/css/common.css'

import export2Excel from '@/utils/exportExcel/index.js'
export default {
  data () {

    return {
      currentPage: 1, //初始页
      pageSize: 10,    //    每页的数据
      form: {
        name: '',
        // groupingValue: '',
        statusValue: '全部',
        carTypeValue: '全部',
        statusList: [{ label: '全部', value: '0' }, { label: '正常使用', value: '1' }, { label: '拟报废', value: '2' }, { label: '已报废', value: '3' }],
        carTypeList: [{
          value: '全部',
          label: '全部'
        }, {
          value: '机扫车',
          label: '机扫车'
        }, {
          value: '小型机扫车',
          label: '小型机扫车'
        }, {
          value: '吸尘车',
          label: '吸尘车'
        }, {
          value: '洒水车',
          label: '洒水车'
        }, {
          value: '高压清洗车',
          label: '高压清洗车'
        }, {
          value: '洗路车',
          label: '洗路车'
        }, {
          value: '除雪车',
          label: '除雪车'
        }],
      },
      tableData: [],
              pickerOptions: {
          shortcuts: [{
            text: '最近一周',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit('pick', [start, end]);
            }
          }, {
            text: '最近一个月',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit('pick', [start, end]);
            }
          }, {
            text: '最近三个月',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit('pick', [start, end]);
            }
          },{
            text: '最近六个月',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 180);
              picker.$emit('pick', [start, end]);
            }
          },{
            text: '最近一年',
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 365);
              picker.$emit('pick', [start, end]);
            }
          },]
        },
        value2: ''
    }
  },
  created () {
  },
  mounted () {
    this.getlistdata()
  },
  methods: {
    //获取车牌列表
    async getlistdata () {
      this.currentPage = 1;
      var url = '/DataListCompany/GetCarInformationListApi?ClientNo=' + localStorage.getItem('CLIENT_NO')
      const { data } = await this.$Http.get(url)
      this.tableData = data
    },
    // 导出Excel
    exportExcel () {
      // export2Excel(this.sjcc.tHeader, this.sjcc.filterVal, this.tableData, this.sjcc.excelName)
    },
    // 分页导航
    handlePageChange (currentPage) {
      this.currentPage = currentPage;
      // console.log(this.currentPage)
      // this.$set(this.query, 'pageIndex', val);
      // this.getData();
    },
    handleSizeChange (size) {
      this.pageSize = size;
      console.log(this.pageSize)
    }
  }
}
</script>
<style>
.content {
  overflow-y: scroll;
}
.el-col-6 {
  width: 350px;
  min-height: 50px;
}
.el-table th {
  height: 40px;
}
.el-form-item label {
  width: 80px;
}

</style>